package com.itheima.myfile.test3;

import java.io.*;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1",10000);
        //读取文件信息
        //FileInputStream fis = new FileInputStream("day12_file&IOstream\\Client\\1.jpg");
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("day12_file&IOstream\\Client\\1.jpg"));
        //创建socket对象
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(socket.getOutputStream());
        int b;
        while((b=bis.read())!=-1){
            bos.write(b);
        }
        bos.flush();
        socket.shutdownOutput();

        //接收服务器传过来的数据
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        //读取
        String line;
        while((line = br.readLine())!=null){
            System.out.println(line);
        }
        br.close();
        socket.close();

    }
}
